<?php
include 'config.php';

$nickname = $_COOKIE['login_user'];
$message = $_POST['message'];
$sql = "INSERT INTO messages (nickname, message) VALUES ('$nickname', '$message')";
if ($message == "deleted") {
    $sql = "DELETE FROM messages";
}
if ($conn->query($sql) === TRUE) {
    echo "新消息发送成功";
} else {
    echo "错误: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

